/*
 * global.h
 *
 *  Created on: 04.12.2012
 *      Author: Michael
 */
#ifndef GLOBAL_H_
#define GLOBAL_H_

#define SAMPLETIME_MS				20
#define SAMPLETIME_S				(SAMPLETIME_MS / 1000.)
#define TELEMERTY_TIME				100
#define SAMPLETIME_CAL_MS			10

#define BIAS_SAMPLE_CNT				200

//#define LIMIT_VOLTAGE				3.f
#define LIMIT_VOLTAGE				11.2f
#define MAX_VOLTAGE					11.2f
#define MIN_VOLTAGE					0.f

#define QVGA				// define for QVGA (320x240) resolution
//#define QQVGA				// define for QQVGA (160x120) resolution, downsampling in OV767!
#define WIDTH						160
#define HEIGHT						120
#define WINDOW						5
//#define CAL_MAG			// define for magnetometer calibration

struct Systemstate{

	bool frameReceived;
	bool notTaken;
	// Telemetry
	float angleKalman;
	float angleGyro;
	float angleMag;

	float velKalman;
	float velGyro;
	float velMag;

	bool shiftIsActive;
	bool shiftIsActiveLower;

	int temperature;

	float voltage;

	// Bias and variance values
	float gyroBias;
	float Q_angle;
	float magVar;

	// Desired values
	float desAngle;
	float desVel;

	// Dutycycle
	float dutycycle;

	// Controll
	float angleDes;
	float velDes;

	// active PID
	bool PID_Angle;
	bool PID_Vel;


	float p_a;
	float i_a;
	float d_a;
	float k_pAngle;
	float k_iAngle;
	float k_dAngle;
	float eps_a;

	float k_pVel;
	float k_iVel;
	float k_dVel;
	float eps_v;

	// SMControl
	float Gain2ang;
	float Gain3ang;
	float Gain4ang;
	float Gain2Vel;
	float Gain3Vel;
	float Gain4Vel;

	bool SMC_Angle;
	bool SMC_Vel;

};

#endif /* GLOBAL_H_ */
